function do_shadow(left_pos, top_pos) {
    if(!left_pos) {left_pos=5;}
    if(!top_pos) {top_pos=7;}

    if($("#wrapper").length > 0) {
        $("#wrapper").dropShadow({color:"#000", opacity:0.8, left: left_pos, top: top_pos });
    }
    else {
        $("#content").dropShadow({color:"#59321B", opacity:0.8, left: left_pos, top: top_pos });
    }
}

function adjust_to_viewport() {
    var w = $('body').width();
    $('#overlay').show();
    if($.browser.msie && $.browser.version == 6) {
        if(w > 1024) {
            $('#content').css("margin-left", "8%");
        }
        else {
            $('#content').css("margin-left", "4%");
        }
    }
    else {
        if(w > 1024) {
            $('#content').css("margin-left", "20%");
        }
        else {
            $('#content').css("margin-left", "10%");
        }
    }
    $('#overlay').hide();
}

function fix_png() {
    if ($.browser.msie && $.browser.version == 6) {
        $("body").supersleight();
    }
}

function attach_faq_events() {
    $("h5.clickable").click(function() {
        el = $(this).siblings();
        
        if($(el).css("display") == "none") {
            $(el).slideDown(500);
        }
        else {
            $(el).slideUp(500);
        }
    });

    $("div.hidden_area").hide();
}

function set_min_height() {
    if($.browser.msie && $.browser.version == 6) {
        if($("#faq_page").length > 0){
            $("#faq_page").css("height", "25em");
        }
        else if($("#locations_page").length > 0) {
            $("#locations_page").css("height", "20em");
            $(".location_wrapper").css("height", "14em");
        }
    }
}

function get_maps() {
    if($('#locations_page').length > 0) {
        $("#brampton_office").jmap('init', { 'mapType':  G_NORMAL_MAP, 'mapCenter': [43.694314423098085, -79.76799488067627], 'mapZoom': 15}).jmap('AddMarker', {'pointLatLng': [43.694314423098085, -79.76799488067627]});
        $("#toronto_office").jmap('init', { 'mapType':  G_NORMAL_MAP, 'mapCenter': [43.6624761, -79.3764286], 'mapZoom': 15}).jmap('AddMarker', {'pointLatLng': [43.6624761, -79.3764286]}); 
    }
}

function loadGAScript() {
    if (!document.getElementsByTagName) { return false; }
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

    var gaScript = document.createElement("script");
    gaScript.setAttribute("src", gaJsHost + "google-analytics.com/ga.js");
    gaScript.setAttribute("type", "text/javascript");
    var domHead = document.getElementsByTagName("head")[0];
    domHead.appendChild(gaScript);
}

function callGA() {
    var pageTracker = _gat._getTracker("UA-3738060-5");
    pageTracker._initData();
    pageTracker._trackPageview();
}

$(document).ready(function() {
    fix_png();
    set_min_height();
    attach_faq_events();
    get_maps();
    adjust_to_viewport();
    loadGAScript();
    callGA();

    $(window).resize(function(){
       adjust_to_viewport();
    });
});
//future API points
//$("#sidebar, #otherbar, #footer").equalizeHeightWith($("main"));
//$("#sidebar, #main").equalizeHeightWithEachOther();